home *** CD-ROM | disk | FTP | other *** search
- /* ------------------------------------------------------------------------------
-
- FILENAME
- DespoolPageMessage.c
-
- DESCRIPTION
- This file contains the message procedure that will be invoked when the Printing Manager
- issues the DespoolPage message. The routine which is called is DespoolPageMessageProc.
- Depending upon the effects the user selected in the Addition's Print dialog panel,
- DespoolPageMessageProc will invoke routines in the Additions.c file to produce the
- desired effects.
-
- COPYRIGHT
- Copyright Apple Computer, Inc. 1991
- All rights reserved.
-
- INTERFACE ROUTINES
- DespoolPageMessageProc
-
- MODIFICATION HISTORY
- 05/15/91 ALA Initial Implementation
-
-
- ------------------------------------------------------------------------------- */
-
- #include <Types.h>
- #include <Quickdraw.h>
- #include <Memory.h>
- #include <Resources.h>
- #include <Dialogs.h>
- #include <TextEdit.h>
- #include <OSUtils.h>
- #include <Packages.h>
- #include <ToolUtils.h>
- #include <Menus.h>
- #include <String.h>
- #include <Strings.h>
- #include <Printing.h>
-
- #include <graphics routines.h>
- #include <graphics libraries.h>
- #include <Font Library.h>
-
- #include <Collections.h>
- #include <Messages.h>
-
- #include <PrintingManager.h>
- #include <PrintingMessages.h>
-
- #include "Utilities.h"
- #include "Additions.h"
-
-
- /*================================== MESSAGE INTERFACE ROUTINES ==================================*/
-
-
- /* ===== DespoolPageMessageProc =====
-
- DespoolPageMessageProc is the extension's routine which will be invoked when Printing issues a
- despoolPage message. This routine will first make sure the page is despooled by calling
- Forward_DespoolPage. Once the page is despooled, it checks to see if a page border should
- be added to the page. If so, the AddPageBorder routine is called. It also checks to
- see if we're to serialize the copies. If so, a shape is created which will
- be used to add the serial number to the page at render page time.
- */
- OSErr DespoolPageMessageProc( // (out) Error code
- gxSpoolFile theSpoolFile, // (in) Reference to the spool file being written to
- long pageNum, // (in) Number of the page being despooled
- gxFormat theFormat, // (in) Format reference for the page being spooled
- gxShape *thePage, // (out) The page shape being despooled; we may add items to the page
- Boolean *formatChanged) // (out) true => format changed since last despooled page; false otherwise
- {
-
- OSErr anErr;
-
- /* Make sure the page is despooled before we access it */
- anErr = Forward_GXDespoolPage (theSpoolFile, pageNum, theFormat, thePage, formatChanged);
- if (anErr == noErr)
- {
- gxJob documentJob;
- Collection jobCollection;
- AdditionsCollection additionsConfig;
-
- /* Get a reference to the current job */
- documentJob = GXGetJob();
-
- /* Get reference to the print Job's collection */
- jobCollection = GXGetJobCollection(documentJob);
-
- /* Fetch the Additions's collection we created at Print dialog time */
- anErr = GetCollectionItem (jobCollection,
- kAdditionsCollectionType,
- gxPrintingTagID,
- nil,
- &additionsConfig);
- if (anErr == noErr)
- {
- /* If user selected the page border addition, add it now */
- if (additionsConfig.addPageBorder)
- {
- gxJobInfo printerInfo;
-
- /* Get the general printing info. collection item */
- anErr = GetCollectionItem (jobCollection,
- gxJobTag,
- gxPrintingTagID,
- nil,
- &printerInfo);
- if (anErr == noErr)
- {
- anErr = AddPageBorder(*thePage, theFormat, printerInfo.documentName);
- }
- }
-
- if (anErr == noErr)
- {
- /* Indicate that we don't have a serial number shape yet. The shape will get */
- /* created at RenderPage message time. */
- if (additionsConfig.serializeCopies)
- {
- gSerialShape = nil;
- }
- }
- }
- else // T => no config; don't do anything
- anErr = noErr;
- }
-
- return(anErr);
- }
- /* DespoolPageMessageProc */
-